{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[1 2 3 4]\n"
     ]
    }
   ],
   "source": [
    "import numpy as np\n",
    "arr1 =np.array([1,2,3,4])\n",
    "print(arr1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[[ 1  2  3  4]\n",
      " [ 4  5  6  7]\n",
      " [ 7  8  9 10]]\n"
     ]
    }
   ],
   "source": [
    "arr2=np.array([[1,2,3,4],[4,5,6,7],[7,8,9,10]])\n",
    "print(arr2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "(3, 4)\n",
      "2\n",
      "12\n",
      "int32\n",
      "4\n"
     ]
    }
   ],
   "source": [
    "print(arr2.shape)\n",
    "print(arr2.ndim)\n",
    "print(arr2.size)\n",
    "print(arr2.dtype)\n",
    "print(arr2.itemsize)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[[ 1  2  3  4  4  5]\n",
      " [ 6  7  7  8  9 10]]\n"
     ]
    }
   ],
   "source": [
    "arr2.shape=2,6\n",
    "print(arr2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[0 1 2 3 4 5 6 7 8 9]\n",
      "[[0 1 2 3 4]\n",
      " [5 6 7 8 9]]\n"
     ]
    }
   ],
   "source": [
    "arr3=np.arange(0,10,1)\n",
    "print(arr3)\n",
    "arr3.shape=2,5\n",
    "print(arr3)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[ 0.    1.25  2.5   3.75  5.    6.25  7.5   8.75 10.  ]\n"
     ]
    }
   ],
   "source": [
    "arr4=np.linspace(0,10,9)\n",
    "print(arr4)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[0. 0. 0. 0. 0. 0. 0. 0. 0. 0.]\n",
      "[0. 0. 0. 0. 0. 0. 0. 0. 0. 0.]\n"
     ]
    }
   ],
   "source": [
    "arr5=np.zeros(10)\n",
    "print(arr5)\n",
    "arr6=np.linspace(0,0,10)\n",
    "print(arr6)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[0.99188304 0.09712981]\n"
     ]
    }
   ],
   "source": [
    "arr7=np.random.random(2)\n",
    "print(arr7)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[0.08226048 0.11768754 0.65802733 0.95284106 0.79106525 0.41614053\n",
      " 0.50679993 0.78941298 0.32210309 0.80847258]\n"
     ]
    }
   ],
   "source": [
    "arr8=np.random.rand(10)\n",
    "print(arr8)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[[ 1  2  3  4  4  5]\n",
      " [ 6  7  7  8  9 10]]\n",
      "[2 3 5]\n"
     ]
    }
   ],
   "source": [
    "print(arr2)\n",
    "print(arr2[0,(1,2,5)])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[ True False  True]\n"
     ]
    },
    {
     "ename": "NameError",
     "evalue": "name 'arr' is not defined",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mNameError\u001b[0m                                 Traceback (most recent call last)",
      "\u001b[1;32m<ipython-input-11-6dde50ccd29e>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m\u001b[0m\n\u001b[0;32m      1\u001b[0m \u001b[0mmask\u001b[0m\u001b[1;33m=\u001b[0m\u001b[0mnp\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0marray\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m[\u001b[0m\u001b[1;36m1\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;36m0\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;36m1\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m,\u001b[0m\u001b[0mdtype\u001b[0m\u001b[1;33m=\u001b[0m\u001b[0mnp\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mbool\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m      2\u001b[0m \u001b[0mprint\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mmask\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m----> 3\u001b[1;33m \u001b[0mprint\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0marr\u001b[0m\u001b[1;33m[\u001b[0m\u001b[0mmask\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;36m2\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m",
      "\u001b[1;31mNameError\u001b[0m: name 'arr' is not defined"
     ]
    }
   ],
   "source": [
    "mask=np.array([1,0,1],dtype=np.bool)\n",
    "print(mask)\n",
    "print(arr[mask,2])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "(12,)\n",
      "1\n"
     ]
    }
   ],
   "source": [
    "arr=np.arange(12)\n",
    "print(arr.shape)\n",
    "print(arr.ndim)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[ 1  2  3  4  4  5  6  7  7  8  9 10]\n",
      "[ 1  6  2  7  3  7  4  8  4  9  5 10]\n",
      "[ 1  2  3  4  4  5  6  7  7  8  9 10]\n"
     ]
    }
   ],
   "source": [
    "print(arr2.ravel())\n",
    "print(arr2.flatten('F'))\n",
    "print(arr2.flatten())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[[ 0  3  6  9]\n",
      " [12 15 18 21]\n",
      " [24 27 30 33]]\n",
      "[[ 0  1  2  3  0  3  6  9]\n",
      " [ 4  5  6  7 12 15 18 21]\n",
      " [ 8  9 10 11 24 27 30 33]]\n",
      "[[ 0  1  2  3]\n",
      " [ 4  5  6  7]\n",
      " [ 8  9 10 11]\n",
      " [ 0  3  6  9]\n",
      " [12 15 18 21]\n",
      " [24 27 30 33]]\n"
     ]
    }
   ],
   "source": [
    "arr1=np.arange(12).reshape(3,4)\n",
    "arr2=arr1*3\n",
    "print(arr2)\n",
    "arr3=np.hstack((arr1,arr2))\n",
    "print(arr3)\n",
    "arr4=np.vstack((arr1,arr2))\n",
    "print(arr4)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[array([[0, 1],\n",
      "       [4, 5],\n",
      "       [8, 9]]), array([[ 2,  3],\n",
      "       [ 6,  7],\n",
      "       [10, 11]])]\n"
     ]
    }
   ],
   "source": [
    "print(np.hsplit(arr1,2))"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
